<?php

namespace app\common\model;

/**
 * [ManagerCompany  法师寺院表]
 * @author [C。]
 * @return html
 */
class ManagerCompany extends Base
{
    protected $name = 'manager_company';
    /**
     * 根据搜索条件获取总条数
     */
    public function insertdata($data)
    {
        $id = $this->insert($data);
        return $id;
    }
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlist($map,$from = 0, $size = 5,$field = '*')
    {
        $order = ['id' => 'desc'];
        $result =  $this->field($field)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getCount($map)
    {
        $result =  $this->where($map)->count();
        return $result;
    }
    /**
     * 根据搜索条件获取列表信息
     */
    public function getByConditons($map, $from=0, $size = 5,$field = 'am.id,am.tel,m.username,am.img,mc.mid')
    {
        $order = ['m.info'=>'desc','m.id'=>'asc'];
        $join2 = [
            ['app_manager m','mc.mid = m.id'],
        ];
        $join1 = [
            ['app_member am','am.tel = m.tel'],
        ];

        $result =  $this->field($field)
            ->alias('mc')
            ->join($join2)
            ->join($join1)
            ->where($map)
            ->limit($from, $size)
            ->order($order)
            ->select();

        return $result;
    }
    /**
     * 根据搜索条件获取列表信息
     */
    public function getByCount($map)
    {
        $join2 = [
            ['app_manager m','mc.mid = m.id'],
        ];
        $join1 = [
            ['app_member am','am.tel = m.tel'],
        ];

        $result =  $this->alias('mc')
            ->join($join2)
            ->join($join1)
            ->where($map)
            ->count();

        return $result;
    }
}